<?php require ('./order.php'); ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html>
<title></title> 
<?php  
session_start();  
//echo $_SESSION['Role'];
//echo $_SESSION['Pleader'];
?>
<body>
<?php
$Pleader=$_SESSION['Pleader'];
$Role = $_SESSION['Role'];

$rows= array();
$row3= array();
$row5= array();
$sqlllll="select * from AX_replace_col_options where Col='U_OrderId' ";
$arr6=odbc_exec($sqlconnection,$sqlllll);
while($rowwww=odbc_fetch_array($arr6)){
$row5[]=$rowwww;
}
$sqll="select * from AX_replace_col_options where Col='U_RepalceType'";
$arr3=odbc_exec($sqlconnection,$sqll);
while($row=odbc_fetch_array($arr3)){
$rows[]=$row;
}
$sqlll="select * from AX_Replace_Users where Role='Susers'";
$arr4=odbc_exec($sqlconnection,$sqlll);
while($roww=odbc_fetch_array($arr4)){
$row3[]=$roww;
}
 odbc_close($sqlconnection);
$sqlquery="select T0.[RelatedTable],T0.[RelatedColumn],T1.Description from [dbo].[AX_Replace_Role_Right] T0 left join [dbo].[AX_Order_Column_Display] T1 ON T0.[RelatedTable]=T1.[RelatedTable] AND
T0.[RelatedColumn]=T1.[RelatedColumn] WHERE T0.[role]='".$Role."' and T0.IsVisable='Y' order by visorder";
$datelist=array();
$title="";
//echo $sqlquery;
$arr=odbc_exec($sqlconnection,$sqlquery); 
$sqlmid='';
$sqlleft='Select 0';
// 使用while语句循环mysql_fetch_array()函数返回的数组
while($result=odbc_fetch_array($arr)){
$sqlmid=$sqlmid.','.$result['RelatedColumn'];
$title=$title."
<th>".iconv("GB18030//IGNORE","utf-8",$result['Description'])."</th>";
$colid[]=$result['RelatedColumn'];
}

$sqlright="from AX_replace_order where U_CardName ";
$ownsql=$sqlleft.$sqlmid.$sqlright;
//ECHO $ownsql;
$arr2=odbc_do($sqlconnection,$ownsql);
$mx=count($colid);
?>
<center>
<div class="div-relative"> 
<div class="div-a">
<form id="Form1" name="contact" action="add.php" method="POST">
<table id="example1" class="tblGrid">
<thead>
      
        <tr>
 
          <td ><label /></td> 
           <td ><label  /></td> 
           
              <td ><label></label></td> 
               <td ><label /></td> 

               

               <td ><label  /></td> 
                <td ><label  /></td> 
<?php
while($result2=odbc_fetch_array($arr2)){
$LINEID++;
echo "<tr>";   
for($x=0;$x<$mx;$x++) {
if($colid[$x]=="U_OrderId"){
echo "<td><input id ='aa".$LINEID."' value='".$result2[$colid[$x]]."' readonly></input></td>";
}
if($colid[$x]=="U_ItemCode"){
echo "<td>";
echo "<input id='itemcode".$LINEID."' value='".$result2[$colid[$x]]."' readonly />";
echo "</td>";
}
if($colid[$x]=="U_Qty"){
echo "<td>";

echo $result2[$colid[$x]];
echo "</td>";
}
if($colid[$x]=="U_CardName"){
  
  echo "<td>".iconv("GB18030","utf-8//IGNORE",$result2[$colid[$x]])."</td>";
 
}

if($colid[$x]=="RepalceType"){
echo "<td>";
echo "<select name='name' id='status".$LINEID."'>"; 
echo '<option value="D3">小仓</option>';
echo '<option value="D1">大仓</option>';
echo '<option value="D2">大仓加料</option>';
echo "</select>";
echo "</td>";
}
if($colid[$x]=="U_OStatus"){
echo "<td>";
echo "<select name='name2' id='sta".$LINEID."'>"; 
echo '<option value="1">未处理</option>';
echo '<option value="3">待处理</option>';
echo "</select>";
echo "</td>";
}
if($colid[$x]=="Susers"){
echo "<td>";
echo "<select name='name1' id='susers".$LINEID."'>";
echo "<option />";
for($i=0;$i<count($row3);$i++){
echo '<option value="'.$row3[$i]['UserName'].'">'.iconv("GB18030","utf-8//IGNORE",$row3[$i]['UserName']).'</option>';
}
echo "</select>";
echo "</td>";
}

?>
</table>
</form>
</div>
</div>
</center>
</body>	
</html>